Load dependencies

Load imager

Show dimension of an image

plant<- load.image('~/Documents/Github/PhD//imageprocessing/burseragrav1.jpg')
dim(plant)
## [1] 1400 2100    1    3

Image

plot(plant)

## Y-axis shift

imshift(plant,0,50) %>% plot

## X-Axis

imshift(plant,50,0) %>% plot

Both Axis Shift

imshift(plant,50,50) %>% plot

Resize the image

map_il(2:4,~ imresize(plant,1/.)) %>% imappend("x") %>% plot

Rotate

imrotate(plant,30) %>% plot

Convert To Black & White

grayscale(plant) %>% plot

Mask Cut

msk <- px.flood(plant,400,900,sigma=.28) %>% as.cimg
inv<- msk %>%as.data.frame
inv$value<- as.numeric(inv$value==0)
msk<- inv %>% as.cimg()
## Warning in as.cimg.data.frame(.): Guessing image dimensions from maximum
## coordinate values
plot(msk*plant)

Filter out data using a set of pixels based on either EBG or HSV values

indicatorMatrix <-function( test,xrange,yrange,types)
{

if(types=='RBG'){
newtest<- test %>% as.data.frame} else{newtest<-RGBtoHSV(test) %>% as.data.frame}   
dfnew<-subset(newtest, x%in%xrange & y%in%yrange) %>% ddply( .(cc),summarize,SD = sd(value, na.rm=TRUE),Mean = mean(value, na.rm=TRUE))

tmp<-subset(newtest,cc==1)
tmp$value<-as.numeric( between (newtest$value[newtest$cc==1] , unlist(dfnew[1,3]-dfnew[1,2]), unlist(dfnew[1,3]+dfnew[1,2]) ) & between ( newtest$value[newtest$cc==2 ] , unlist(dfnew[2,3]-dfnew[2,2]), unlist(dfnew[2,3]+dfnew[2,2]))
    & between ( newtest$value[newtest$cc==3] , unlist(dfnew[3,3]-dfnew[3,2]), unlist(dfnew[3,3]+dfnew[3,2])))

newtest$value<- rep(tmp$value,3) *newtest$value
tester<- newtest %>% as.cimg
return(list(tester,tmp,dfnew))
}
samplemat3<- indicatorMatrix(plant,900:1000 ,850:950,'RBG')
## Warning in as.cimg.data.frame(.): Guessing image dimensions from maximum
## coordinate values
#Isolate Leaves
plot(samplemat3[[1]])